#ifndef _COBJECT_H_
#define _COBJECT_H_

#include <d3dx9.h>
#include "Sprite.h"
#include "Input.h"
#include "Camera.h"

enum OBJECT_TYPE
{
	OBJECT_MARIO, OBJECT_LAND, OBJECT_PIPE, OBJECT, OBJECT_ENEMY
};

class CObject
{
protected:
	D3DXVECTOR2 m_pos;
	D3DXVECTOR2 m_posLast;
	CSprite* m_sprite;
	RECT m_rectBond;
	BOOL m_isAlive;
	BOOL m_isVisible;
	BOOL m_isCollision;
	D3DXVECTOR2 m_velocity;
	D3DXVECTOR2 m_velocityLast;
	D3DXVECTOR2 m_acceleration;
	void UpdateBond();

public:
	D3DXVECTOR2 m_collisionResponse;
	CObject();
	CObject(D3DXVECTOR2 pos);
	virtual void Init();
	virtual void Update(float gameTime, CInput* input); // Update vi tri
	virtual void Draw(LPD3DXSPRITE spriteHandler, CCamera* camera);
	virtual OBJECT_TYPE GetType();
	void UpdatePosition(float gameTime, CInput* input);
	void UpdatePosition(float collisionTime);
	virtual void UpdateAnimation(float gamTime, CInput* input);
	void UpdateResponse(float gameTime, CInput* input);
	bool IsCollideWith(CObject* another);
	RECT GetIntersectBond(CObject* another);
	bool IsPointIn(D3DXVECTOR2 point);
	void SetLastPosition();

	RECT GetBond() { return m_rectBond; }
	void SetPosition(D3DXVECTOR2 pos)
	{
		m_pos = pos;
	}
	void SetVelocity(D3DXVECTOR2 vel)
	{
		m_velocity = vel;
	}
	void SetVelocityX(float x)
	{
		m_velocity.x = x;
	}
	void SetVelocityY(float y)
	{
		m_velocity.y = y;
	}
	void SetAcceleration(D3DXVECTOR2 acc)
	{
		m_acceleration = acc;
	}
	void SetAccelerationY(float y)
	{
		m_acceleration.y = y;
	}
	void SetAccelerationX(float x)
	{
		m_acceleration.x = x;
	}

	D3DXVECTOR2 GetAcceleration()
	{
		return m_acceleration;
	}
	D3DXVECTOR2 GetVelocity()
	{
		return m_velocity;
	}

};


#endif